
package com.zm.tools.validate.core;

/**
 * Description: 中英文正则验证
 * Created by zoum on 2018/6/6 15:40.
 */
public class ChineseValidator extends BaseValidator {


    /**
     * 默认长度不限制
     * @param s 字符串
     * @return
     */
    public static boolean validate(String s) {
        String regex = "^([\u4e00-\u9fa5\\.])*$";
        return validate(s, regex);
    }

    /**
     * 固定长度中文验证
     * @param s
     * @param digit
     * @return
     */
    public static boolean validate(String s, int digit) {
        String regex = "^[\u4e00-\u9fa5]{"+ digit +"}$";
        return validate(s, regex);
    }
    /**
     * 范围长度中文验证
     * @param s
     * @param minDigit
     * @param maxDigit
     * @return
     */
    public static boolean validate(String s, int minDigit, int maxDigit) {
        String regex = "^[\u4e00-\u9fa5]{"+ minDigit +"," + maxDigit +"}$";
        return validate(s, regex);
    }
}
